<?php require_once('auth.php'); ?>
<html>
<head>
<title>MCS Image Tool</title>
<script type="text/javascript" src="simpletreemenu.js"></script>
<link rel="stylesheet" type="text/css" href="simpletree.css" />
</head>
<body>
<div style='background-color:#f8f8f8; width:30%; margin:0px auto 50px; padding:0px; border-radius:10px; border:1px solid #808080; box-shadow:8px 15px 20px #404040'>
<center><a href="javascript:ddtreemenu.flatten('treemenu3', 'expand')" style="font-family:'Arial';font-size:14pt;color:black;">Expand All</a> | <a href="javascript:ddtreemenu.flatten('treemenu3', 'contact')"style="font-family:'Arial';font-size:14pt;color:#000000;">Collapse All</a>
</center></div>

<!--<div style="width:25%;border: 1px solid black;background-color:#ffffff; layer-background-color:#003366; visibility: visible"> -->
 <div id="tree" style="float:left; width:25%; border: 1px solid black;"> 
<ul id="treemenu3" class="treeview">
<?php
      session_start(); 
   include  "scandr2.php"	;
      
      //$path =  $_SERVER['DOCUMENT_ROOT'].'/badge/uploads';
      //$path = "/opt/lampp/htdocs/music/music";
      //$path = "/opt/lampp/htdocs/badge5/uploads";
        $path = "/home/rockedg1/public_html/badge/uploads";
      
      $songs = array();
      $iii = 0;
      $filestructure= scan_directory_recursively($path, false);
//    $filestructure = scan_directory_recursively($path, mp3);

foreach($filestructure as $content) {

 $songs[$iii][path] = $content[path];
 $songs[$iii][name] = $content[name];
 $songs[$iii][kind] = $content[kind];
 $songs[$iii][size] = $content[size];
 $songs[$iii][content] = $content[content];		 
		 
			 
++$iii;
}


	  $data = orderBy($songs, 'name');

foreach($data as $subcontent) {

  if ($subcontent[kind] =='directory'){
	 echo "<li>".$subcontent[name]."\n";
	 echo "<ul>"."\n";;

     echo scan_dd($subcontent[content]);
     echo "</ul>"."\n";

  }else{
         if ($subcontent[kind] =='file'){
         //$path = $subcontent[path];
         //echo "<li>".$subcontent[name]."</li>";
         //echo "<li><a href='make_str3.php?id=".$subcontent[path]."' target='iFrame1'>".$subcontent[name]."</a></li>"."\n";
#         echo "<li><a href='show_img.php?id=".$subcontent[path]."' target='iFrame1'>".$subcontent[name]."</a></li>"."\n";
           echo "<li><a href='display-photo_multi.php?id=".$subcontent[path]."' target='iFrame1'>".$subcontent[name]."</a></li>"."\n";
         }
       }
}



 function scan_dd($array){
 
 foreach($array as $subcontent) {
 $songs[$i][path] = $subcontent[path];
 $songs[$i][name] = $subcontent[name];
 $songs[$i][kind] = $subcontent[kind];
 $songs[$i][size] = $subcontent[size];
 $songs[$i][content] = $subcontent[content];
    if ($songs[$i][kind] =='directory'){
		 echo "<li>".$subcontent[name]."\n";
	 echo "<ul>"."\n";;
	$go_array = $subcontent[content];
	echo scan_dd ($go_array);
    echo "</ul>"."\n";
    }
++$i;
}
$data = orderBy($songs, 'name');

  foreach($data as $subcontent) {

    if ($subcontent[kind] =='file'){
         //$path = $songs[$i][path];
         //echo "<li>".$subcontent[name]."</li>";
         //echo "<li><a href='make_str3.php?id=".$subcontent[path]."' target='iFrame1'>".$subcontent[name]."</a></li>"."\n";
         echo "<li><a href='show_img.php?id=".$subcontent[path]."' target='iFrame1'>".$subcontent[name]."</a></li>"."\n";
         }

    }

}

function orderBy($data, $field) { 
	$code = "return strnatcmp(\$a['$field'], \$b['$field']);";
	usort($data, create_function('$a,$b', $code));
	 return $data;
} 

function get_path($path) {
  $len = strlen($path);
  $pos = strpos($path,'/uploads/');
  $http_path =  substr($path,$pos,$len);
	  return $http_path;
}	  



?>
</ul>
<script type="text/javascript">
ddtreemenu.createTree("treemenu3", true)
</script>
<!--<div id="iFrame1"> -->
<!--<div id="iFrame1" style="float:left;"> -->
<!--<div id="iFrame1" style="position:fixed; left:780px; top:241px; z-index:6"> -->
<!--<div id="iFrame1" style="float:right;">	-->
<!--<div id="iFrame1" style="position:absolute; left:514px; top:441px; z-index:6">	-->
<!--<iframe name="iFrame1" width="400" height="340" src="blank.php" scrolling="no" frameborder="0"></iframe> -->
<script language="javascript">
var popupWindow = null;
function centeredPopup(url,winName,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
popupWindow = window.open(url,winName,settings)
}
</script>

</div>
<!--<div id="exco" style="position:fixed; left:800px; top:100px"> -->
<div id="exco" style="float:left;padding-left: 10px;"> 
<iframe name="iFrame1" width="400" height="340" src="blank.php" scrolling="no" frameborder="0"></iframe>
</div>
<div id="exco1" style="float:left;padding-left: 10px;"> 
<form name="form1" method="post" action="insert_photo.php" enctype="multipart/form-data" style="margin:0px" target='iFrame1'>
<input name="datei" type="file" >
<input name="formbutton1" type="submit" value="Upload!" >
<input name="formbutton2" type="reset" value="Clear" >
</form>
<p><a href="parse_5.php"><img src="images/refresh.png" alt="missing">&nbsp;&nbsp;Refresh File Tree</a></p>
<p><a href="show_url2.php" onclick="centeredPopup(this.href,'myWindow','500','100','yes');return false"><img src='images/add.png' alt='Show URL'>&nbsp;&nbsp;Show URL</a></p>
</div>
</div>
</body>
</html>
